package zdream.pmfield.stage.director;

/**
 * @author Zdream
 * @date 2023-11-14
 * @since 0.0.1
 */
public class Damages {
	public static int damage(AttackContext.AttackContextItem item) {
		final AttackContext context = item.parent;
		if (item.targetFoe == null) {
			return 0;
		}

		final float typeFixed = item.typeFixed;
		final int power = context.power;

		if (typeFixed == 0 || power == 0) {
			return 0;
		}

		final short level = context.attacker.foe.level;
		final int attack = context.attack;
		final int defense = item.defense;
		final float effectFixedAttack = context.effectFixed;
		final float effectFixedDefense = item.defenseFixed;

		int damage = (int) ((((2 * level + 10) * attack * power) / (250f * defense) + 2)
				* typeFixed * effectFixedAttack / effectFixedDefense);
		return Math.max(1, damage);
	}
}
